{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e6f9eba5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6f195d70",
   "metadata": {},
   "outputs": [],
   "source": [
    "def yaml_config_reader(yaml_file:os.path):\n",
    "    if(os.path.isfile(yaml_file)):        \n",
    "        print(\"Reading config data from file:\\n{}\".format(yaml_file))\n",
    "        with open(yaml_file, mode='r', encoding='utf-8') as f:\n",
    "            config = yaml.load(f.read(), Loader=yaml.FullLoader) \n",
    "    return config "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "66ca79b0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reading config data from file:\n",
      "D:\\deepdotdev\\deepdot-vision\\deepdot_vision\\config\\mvtec\\draem_train_config.yaml\n"
     ]
    }
   ],
   "source": [
    "yamlfile = os.path.join(r\"D:\\deepdotdev\\deepdot-vision\\deepdot_vision\\config\\mvtec\\draem_train_config.yaml\")\n",
    "content = yaml_config_reader(yamlfile)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "313c8b69",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'mvtec_draem'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[1;32mIn [18]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mcontent\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmvtec_draem\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'mvtec_draem'"
     ]
    }
   ],
   "source": [
    "content[\"mvtec_draem\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "48efb16c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['capsule',\n",
       " 'bottle',\n",
       " 'carpet',\n",
       " 'leather',\n",
       " 'pill',\n",
       " 'transistor',\n",
       " 'tile',\n",
       " 'cable',\n",
       " 'zipper',\n",
       " 'toothbrush',\n",
       " 'metal_nut',\n",
       " 'hazelnut',\n",
       " 'screw',\n",
       " 'grid',\n",
       " 'wood']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "content[\"obj_list\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b9e914cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'train_param': {'obj_id': -1,\n",
       "  'bs': 4,\n",
       "  'lr': 0.001,\n",
       "  'epochs': 700,\n",
       "  'gpu_id': 0,\n",
       "  'data_path': '',\n",
       "  'anomaly_source_path': '',\n",
       "  'checkpoint_path': '',\n",
       "  'log_path': '',\n",
       "  'visualize': ''},\n",
       " 'obj_list': ['capsule',\n",
       "  'bottle',\n",
       "  'carpet',\n",
       "  'leather',\n",
       "  'pill',\n",
       "  'transistor',\n",
       "  'tile',\n",
       "  'cable',\n",
       "  'zipper',\n",
       "  'toothbrush',\n",
       "  'metal_nut',\n",
       "  'hazelnut',\n",
       "  'crew',\n",
       "  'grid',\n",
       "  'wood'],\n",
       " 'picked_classes': ['capsule',\n",
       "  'bottle',\n",
       "  'carpet',\n",
       "  'leather',\n",
       "  'pill',\n",
       "  'transistor',\n",
       "  'tile',\n",
       "  'cable',\n",
       "  'zipper',\n",
       "  'toothbrush',\n",
       "  'metal_nut',\n",
       "  'hazelnut',\n",
       "  'crew',\n",
       "  'grid',\n",
       "  'wood']}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24eed3b7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd0d683c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c94c9d5a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
